<?php
require_once APPLICATION_PATH . '/modules/digUi/Exception.php';
/**
 * 
 * Digitalus CMS
 *
 * @package    	Digitalus\Ui
 * @copyright  	Copyright (c) 2009,  Digitalus Media USA (http://digitalusmedia.net)
 * @license    	New BSD License, library/Dig/License.txt
 * @version 	2.0
 * 
 */
class DigUi_Bootstrap extends Zend_Application_Module_Bootstrap 
{
    protected function _initLayout()
    {
        Zend_Layout::startMvc();
        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new DigUi_Plugin_Template());
    }
    
    protected function _initView()
    {
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $view = $viewRenderer->view;
        $modules = array_keys( Dig_Service_Module::listAll() );
        foreach ($modules as $module) {
            $view->addHelperPath( APPLICATION_PATH . '/modules/' . $module . '/views/helpers', ucfirst($module) . '_View_Helper');
        }
        return $view;
    }
    
    protected function _initJquery()
    {
    	$view = $this->getResource('view');
        $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
	    // enable jquery
	    $view->jQuery()->enable();
	    $settings = Dig_Service_Module::settings('digUi');
        $view->jQuery()->setLocalPath($settings['jquery']['path']);
        if(isset($settings['jquery']['javascriptFiles']) && is_array($settings['jquery']['javascriptFiles'])) {
            foreach ($settings['jquery']['javascriptFiles'] as $file) {
                $view->jQuery()->addJavascriptFile($file);
            }
        }
        if(isset($settings['jquery']['css']) && is_array($settings['jquery']['css'])) {
            foreach ($settings['jquery']['css'] as $file) {
                $view->jQuery()->addStylesheet($file);
            }
        }
        $view->jQuery()->setUiLocalPath($settings['jquery']['ui']['path']);	
        $view->jQuery()->addStylesheet($settings['jquery']['ui']['theme']);  
	    $view->jQuery()->uiEnable();
    }

    protected function _initHotkeys() {
        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new DigUi_Plugin_Hotkeys());
    }
    
}
?>